<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="../js/demo.js"></script>
    <style>
        *{padding: 0;margin: 0;}
        html{
            height: 5000px;
        }
        .box{
            width: 200px;
            height: 200px;
            background-color: #6ff;
            padding: 5px;
            border: 2px solid transparent;
            position: absolute;
            left: 100px;
            top: 100px;

        }
        .active{
            border-color: #f00;
        }
    </style>
    <!-- <script>
        console.log(111111);
        // 等待页面所有内容(文档,css,js,image)加载完毕之后  => 执行此函数中的代码 
        window.onload = function(){
            console.log(22222);
            var box = document.getElementsByClassName("box")[0];
            console.dir(box);
        }
    </script> -->
</head>
<body>
    <div class="box one two three"></div>
</body>
<script>
    console.log(33333);
    var box = document.getElementsByClassName("box")[0];
    console.dir(box);

    // 当窗口大小改变时 触发此事件    
    // window.onresize = function(){
    //     console.log("窗口大小发生改变",window.innerWidth,window.innerHeight);
    // }

    // 当页面中的滚动条滚动时 触发此事件
    window.onscroll = function(){
        console.log("scrolling");
    }

</script>
</html>